package com.example.myapplication2030606131wjw;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelStoreOwner;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private EditText edtTxtMainInput;
    private Button btnMainIE,btnMaincall,btnMainmap,btnMaincamera;
    private Intent intent;
    private String input;
    private static Uri uri;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_mainIE:
                input=edtTxtMainInput.getText().toString().trim();
                uri=Uri.parse(input);
                intent= new Intent(Intent.ACTION_VIEW,uri);
                startActivity(intent);
                break;
            case R.id.btn_maincall:
                input=edtTxtMainInput.getText().toString().trim();
                uri=Uri.parse("tel:"+ input);
                intent= new Intent(Intent.ACTION_VIEW,uri);
                startActivity(intent);
                break;
            case R.id.btn_maincamera:
                intent= new Intent(Intent.ACTION_VIEW,uri);
                startActivity(intent);
                break;
            case R.id.btn_mainmap:
                input=edtTxtMainInput.getText().toString().trim();
                uri=Uri.parse("geo:"+ input);
                intent= new Intent(Intent.ACTION_VIEW,uri);
                startActivity(intent);
                break;
        }
    }
        private void initView() {
        edtTxtMainInput = (EditText) findViewById(R.id.edt_txt_main_input);
        btnMainIE = (Button) findViewById(R.id.btn_mainIE);
        btnMaincall = (Button) findViewById(R.id.btn_maincall);
        btnMainmap = (Button) findViewById(R.id.btn_mainmap);
        btnMaincamera = (Button) findViewById(R.id.btn_maincamera);
        btnMainIE.setOnClickListener(this);
        btnMaincall.setOnClickListener(this);
        btnMainmap.setOnClickListener(this);
        btnMaincamera.setOnClickListener(this);
    }
    }
